package com.highcom.exception;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//@Order(value = Ordered.HIGHEST_PRECEDENCE) //数越小，优先级越高
//@Component  //什么异常都有这个类处理
public class CustomerHandlerExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse response, Object o, Exception e) {
        try {
            response.sendError(511,"这是个511错误");
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

        return new ModelAndView();
    }
}
